<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ include file="/common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src='<s:url value="/scripts/CustomTreeUI.js" includeParams="none"/>'></script>
<link rel="stylesheet" type="text/css" href='<s:url value="/scripts/column-tree.css" includeParams="none"/>'/>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/css.css">

<title>主题列表</title>
<script>
var  highlightcolor='#F8EABE';
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var  clickcolor='#fff';
function  changeto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=highlightcolor&&source.id!="nc"&&cs[1].style.backgroundColor!=clickcolor)
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=highlightcolor;
}
}

function  changeback(){
source=event.srcElement;
if  (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="nc")
return
if  (event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor)
//source.style.backgroundColor=originalcolor
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}

function  clickto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=clickcolor&&source.id!="nc")
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=clickcolor;
}
else
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}

	
	function doExport(){
		//if(confirm("如导出失败，请添加查询条件进行数据过滤,使查询出的数据量减少后再进行导出，您确认要导出数据吗？")){
			document.getElementById("strDomainId").value = document.getElementById("qdDomain.id").value;
			document.all.s_user_form.action="qdDomainSearch!doExportForExcel.action";
			document.all.s_user_form.submit();
		//}
	}
	
	function doSaveHis(){
		document.getElementById("strDomainId").value = document.getElementById("qdDomain.id").value;
		document.all.s_user_form.action="qdDomainSearch!load4SaveHisCondition.action";
		document.all.s_user_form.submit();
	}
	
	function goBack(){
		var searchType = document.getElementById("searchType").value;
		document.getElementById("strDomainId").value = document.getElementById("qdDomain.id").value;
		if(searchType=="2"){	
		    document.getElementById("s_user_form").action="qdDomainSearch!load4HightSearch.action";
		}else{			
			document.getElementById("s_user_form").action="qdDomainSearch!load4Init.action";
		}
		document.all.s_user_form.submit();
	}
	
	function changePage(curpage,tag){
		//alert("curpage=="+curpage);
		if(tag=="first"){
			document.getElementById("pageNo").value=curpage*1;
		}else if(tag=="pre"){
			document.getElementById("pageNo").value=curpage*1-1;
		}else if(tag=="local"){
			document.getElementById("pageNo").value=curpage*1;
		}else if(tag=="next"){
			document.getElementById("pageNo").value=curpage*1+1;
		}else if(tag=="end"){
			document.getElementById("pageNo").value=curpage*1;
		}	
		document.getElementById("s_user_form").action="qdDomainSearch!doReSearch.action";
		document.all.s_user_form.submit();
	}
</script>
</head>
<body>
<% 
	int countField = 0 ;
	if(request.getAttribute("countField")!=null && !"".equals(request.getAttribute("countField").toString().trim())){
		countField = Integer.parseInt(request.getAttribute("countField").toString().trim());
	}
	int px=(countField+1)*100+40;

	if(px<1000){	
%>
<div class="main">
<div class="main_title"><b>你当前的位置：</b><s:property value="title" /></div>	 
<%
   	}else{
%>
<div class="main" style="width:<%=px%>px">
<div class="main_title" style="width:<%=px%>px"><b>你当前的位置：</b><s:property value="title" /></div>	 
<%  	
   	}
%>
<s:form id="s_user_form" namespace="/querythemes" action="qdDomainSearch!doReSearch.action">
<s:hidden name="pageSize" id="pageSize"/>
<s:hidden name="qdDomain.id" id="qdDomain.id"/>
<s:hidden name="strSql" id="strSql"/>
<s:hidden name="countField" id="countField"/>
<s:hidden name="condstrcn" id="condstrcn"/>
<s:hidden name="condstr" id="condstr"/>
<s:hidden name="fieldstr" id="fieldstr"/>
<s:hidden name="orderstr" id="orderstr"/>
<s:hidden name="ordertypestr" id="ordertypestr"/>
<s:hidden name="searchType" id="searchType"/>
<s:hidden name="strDomainId" id="strDomainId"/>
<s:hidden name="pageNo" id="pageNo"/>
</s:form>
<% 
	if(px<1000){	
%>
<div class="botton">	 
<%
   	}else{
%>
<div class="botton" style="width:<%=px%>px">	 
<%  	
   	}
%>

	  <s:form id="testDomain" namespace="/querythemes" action="qdDomainSearch!doReSearch.action">
		  <input name="" type="button" value="导 出" class="export" onmouseover="this.className='export_hover'" onmouseout="this.className='export'"  onclick="doExport()"/>	  
		  <input name="" type="button" value="保 存" class="add" onmouseover="this.className='add_hover'" onmouseout="this.className='add'" onclick="doSaveHis()" />
		  <input name="" type="button" value="返 回" class="back" onmouseover="this.className='back_hover'" onmouseout="this.className='back'" onclick="goBack()" />
	  </s:form>
	  <%--<input name="" type="button" value="删除" class="delete" onmouseover="this.className='delete_hover'" onmouseout="this.className='delete'" />
	  <input name="" type="button" value="校验" class="check" onmouseover="this.className='check_hover'" onmouseout="this.className='check'" />
	  <input name="" type="button" value="浏览" class="read" onmouseover="this.className='read_hover'" onmouseout="this.className='read'" />
	   --%>
</div>

<table id="res-table" cellpadding="1" cellspacing="1" class="tablelist"  onmouseover="changeto()"  onmouseout="changeback()">
  <tr class="toptitle">
  	<td>
  		<div style="width:40px"/>
  		序号
  	</td>
  	<s:iterator value="titleFieldList" status="status">
    <td> 
		<% 
			if(px>1000){   	
		%>
		<div style="width:100px"/>
		<%  	
		   	}
		%>	   	 
         <s:property value="name" />
    </td>
    </s:iterator>	
  </tr>
  <tbody>
	<s:iterator value="page.res" status="status">
		<s:if test="#status.even">
		 <tr class="listr1" onmouseover="this.className='listr3'" onmouseout="this.className='listr1'">
		</s:if>
		<s:else>
		 <tr class="listr2" onmouseover="this.className='listr3'" onmouseout="this.className='listr2'">
		</s:else>
			<td>&nbsp;<s:property value="#status.index+1" /></td>
			<% if(countField<=1){ %>
				<s:iterator value="titleFieldList" status="statust">
			    <td> 
			         <s:property value="page.res[#status.index]" />
			    </td>
			    </s:iterator>	
		    <% }else{%>
			   <s:iterator value="titleFieldList" status="statust">
			    <td> 
			         <s:property value="page.res[#status.index][#statust.index]" />
			    </td>
			    </s:iterator>
		    <% }%>
		</tr>
	 </s:iterator>
   </tbody>
</table>


<table class="tablelist" >
<s:set  var="totle" scope="request" value="page.count"/>
<s:set  var="pageSize" scope="request" value="pageSize"/>
<%  
    Integer  count = new Integer(0);
    if(request.getAttribute("totle")!=null){
    	count = (Integer) request.getAttribute("totle");
    }	
	Integer pageSize = (Integer) request.getAttribute("pageSize");
	String pageSizeStr = Integer.toString(pageSize.intValue());
	
	Integer cPageNo = new Integer(0);
	if(request.getAttribute("pageNo")!=null){
		cPageNo = (Integer) request.getAttribute("pageNo");
	}	
%>
		
	<tr>
		<td class="listr4" align="left" colspan="<%=countField+1 %>">		
			<pg:pager  url="qdDomainSearch!doReSearch.action" items='<%=count.intValue()%>'	maxPageItems='<%=pageSize%>' maxIndexPages="1" export="currentPage=pageNumber">				
				<pg:param name="pageSize"/>
				<pg:param name="qdDomain.id"  value='<%=(String)request.getAttribute("strDomainId")%>'/>
				<pg:param name="strDomainId"  value='<%=(String)request.getAttribute("strDomainId")%>'/>				
				<pg:param name="countField" value='<%=((Integer)request.getAttribute("countField")).toString()%>'/>
				<pg:param name="condstrcn" value='<%=(String)request.getAttribute("condstrcn")%>'/>
				<pg:param name="condstr" value='<%=(String)request.getAttribute("condstr")%>'/>
				<pg:param name="orderstr" value='<%=(String)request.getAttribute("orderstr")%>'/>
				<pg:param name="ordertypestr" value='<%=(String)request.getAttribute("ordertypestr")%>'/>
				<pg:param name="searchType" value='<%=(String)request.getAttribute("searchType")%>'/>
				<pg:param name="fieldstr" value='<%=(String)request.getAttribute("fieldstr")%>'/>
				<pg:index export="pages">
					<table>
						<tr>
							<td>
								找到<%=count.intValue()%>条记录 当前<b class="fontred"><%= cPageNo.intValue()%></b>/<%=pages%>页&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
							<td>
								<pg:first>
									<label onClick="changePage('1','first')"><u style="cursor:pointer">首页</u></label>&nbsp;&nbsp;
									<!-- <a href="<%=pageUrl%>&pageNo=<%=pageNumber%>">首页</a> -->
								</pg:first>
							</td>
							<td>
								<%
									if(cPageNo.intValue()>1){
								%>
								     <label onClick="changePage('<%=cPageNo.intValue()%>','pre')"><u style="cursor:pointer">上一页</u></label>&nbsp;&nbsp; 	
								<%
									}								
								%>	
								<pg:prev>									
									<!-- <a href="<%=pageUrl%>&pageNo=<%=pageNumber%>">上一页</a> -->
								</pg:prev>
							</td>
							<td>
								<pg:pages>
								   <%
								    	int countPageNos = pages.intValue();
								    	int cPageNos = cPageNo.intValue();
								    	int startPageNos = 0;
								    	int endPageNos = 0;
								    	
								    	if(countPageNos<=10){
								    		startPageNos = 1;
								    		endPageNos = countPageNos;
								    	}else if(cPageNos<=5){
								    		startPageNos = 1;
								    		if(countPageNos<=10){
								    			endPageNos = countPageNos;
								    		}else {
								    			endPageNos = 10;
								    		}
								    	}else{
								    		if(cPageNos+5>countPageNos){
								    			startPageNos = countPageNos-9;
								    			endPageNos = countPageNos;
								    		}else{
								    			startPageNos = cPageNos-5;
								    			endPageNos = cPageNos+4;
								    		}
								    	}
								    	
								    	
								    	for(int ip=startPageNos;ip<=endPageNos;ip++){
								    		if(ip==cPageNo.intValue()){
								    %>
									<font color="red"><%=ip%></font>&nbsp;&nbsp;
									<%
								    		}else{
								    %>
									<label onClick="changePage('<%=ip%>','local')"><u style="cursor:pointer"><%=ip%></u></label>&nbsp;&nbsp;
									<!-- <a href="<%=pageUrl%>&pageNo=<%=pageNumber%>"><%=pageNumber%></a> -->
									<%		
								    		}
								    	}
								   %>								   
								</pg:pages>
							</td>
							<td>
								<%
									if(pages.intValue()-cPageNo.intValue()>1){
								%>
								     <label onClick="changePage('<%=cPageNo.intValue()%>','next')"><u style="cursor:pointer">下一页</u></label>&nbsp;&nbsp;	
								<%
									}								
								%>	
								<pg:next>
									
									<!-- <a href="<%=pageUrl%>&pageNo=<%=pageNumber%>">下一页</a> -->
								</pg:next>
							</td>
							<td>
								<pg:last>
									<label onClick="changePage('<%=pages%>','end')"><u style="cursor:pointer">末页</u></label>&nbsp;&nbsp;&nbsp;&nbsp;
									<!-- <a href="<%=pageUrl%>&pageNo=<%=pageNumber%>">末页</a>&nbsp;&nbsp;&nbsp;&nbsp; -->
								</pg:last>
							</td>				
							<td>
	 							&nbsp;
							</td>
							<td style="padding-left: 10px;">
								每页显示的记录数
							</td>
							<td>
							    <%=pageSize%>
								<input type="hidden" class="PageInput" value="<%=pageSize %>" onchange="Ext.get('pageSize').dom.value=this.value;Ext.get('s_user_form').dom.submit();"/>
							</td>
							<td>
								条
							</td>
							<td>
								&nbsp;
							</td>
						</tr>
					</table>
				</pg:index>
			</pg:pager>
		</td>
	</tr>
</table>
</div>
</body>
</html>